<template>
  <div class="header">
    <div class="content-wrapper">
      <div class="avatar">
        <img :src="seller.avatar" width="64" height="64">
      </div>
      <div class="content">
        <div class="title">
          <span class="brand"></span>
          <span class="name">{{ seller.name }}</span>
        </div>
        <div class="description">
          <span>{{ seller.description }}</span>/<span>{{ seller.deliveryTime }}</span>分钟送达
        </div>
        <div v-if=" seller.supports" class="supports">
          <span class="icon" :class=" classMap[seller.supports[0].type]"></span>
          <span class="text">{{ seller.supports[0].description }}</span>
        </div>
      </div>
      <div v-if="seller.supports" class="announcement" @click="showDetail">
        <span class="count">{{ seller.supports.length }}个</span>
        <span class="icon-keyboard_arrow_right"></span>
      </div>
    </div>
    <div class="bulletin-wrapper" @click="showDetail">
      <span class="bulletin"></span>
      <span class="text">{{ seller.bulletin }}</span>
      <span class="icon-keyboard_arrow_right"></span>
    </div>
    <div class="background">
      <img :src="seller.avatar" width="100%" height="100%">
    </div>
    <div v-show="detailShow" class="detail" transition="fade">
      <div class="detail-wrapper clearfix">
        <div class="detail-main">
          <h1 class="name"> {{ seller.name }}</h1>
          <div class="star-wrapper">
            <star :size="48" :score="seller.score"></star>
          </div>
          <div class="detail-news">
            <div class="line"></div>
            <div class="text">优惠信息</div>
            <div class="line"></div>
          </div>
          <ul v-if="seller.supports" class="detail-supports">
            <li v-for="(item,index) in seller.supports" class="detail-item">
              <span class="icon" :class="classMap[seller.supports[index].type]"></span>
              <span class="text">{{seller.supports[index].description}}</span>
            </li>
          </ul>
          <div class="detail-notices">
            <div class="line"></div>
            <div class="text">商家公告</div>
            <div class="line"></div>
          </div>
          <p class="detail-bulletin">{{seller.bulletin}}</p>
        </div>
      </div>
      <div class="detail-close" @click="closeDetail">
        <i class="icon-close"></i>
      </div>
    </div>


  </div>
</template>

<script type="text/ecmascript-6">
  import star from '../star/star.vue'

  export default {
    //从vue那儿接受到seller的{}类型的对象
    props: {
      seller: {
        type: Object,
      }
    },
    data() {
      return {
        detailShow: false
      }
    },
    methods: {
      showDetail() {
        this.detailShow = true
      },
      closeDetail() {
        this.detailShow = false
      }
    },
    created() {
      this.classMap = ['decrease', 'discount', 'special', 'invoice', 'guarantee']
    },
    components: {
      star

    }

  }
</script>

<style lang="stylus" rel="stylesheet/stylus">

  @import "../../common/stylus/minix.styl"
  .header
    position relative
    background-color rgba(7, 17, 27, 0.5)
    color: #fff
    overflow hidden
    .content-wrapper
      padding 24px 0 18px 24px
      font-size 0
      position relative
      .avatar
        width 64px
        height 64px
        border-radius 4px
        display inline-block
      .content
        display inline-block
        padding-left 16px
        vertical-align top
        .title
          margin 2px 0 8px 0
          .brand
            display inline-block
            vertical-align top
            width 30px
            height 18px
            bg-image('brand')
            background-size 30px 18px
            background-repeat no-repeat
          .name
            font-size 16px
            color #fff
            font-weight blod
            line-height 18px
        .description
          font-size 12px
          color #fff
          font-weight 200
          line-height 12px
          margin-bottom 10px
        .supports
          .icon
            display inline-block
            width 12px
            height 12px
            background-size 12px 12px
            background-repeat no-repeat
            vertical-align top
            &.decrease
              bg-image('decrease_1')
            &.discount
              bg-image('discount_1')
            &.guarantee
              bg-image('guarantee_1')
            &.invoice
              bg-image('invoice_1')
            &.special
              bg-image('special_1')
          .text
            font-size 10px
            color #fff
            line-height 12px
            margin-left 4px
      .announcement
        position absolute
        right 12px
        bottom 18px
        background-color rgba(0, 0, 0, 0.2)
        padding 0 8px
        line-height 24px
        font-weight 200
        height 24px
        text-align center
        border-radius 12px
        .count
          font-size 10px
        .icon-keyboard_arrow_right
          font-size 10px
    .bulletin-wrapper
      height: 28px
      padding 0 22px 0 12px
      text-overflow ellipsis
      overflow: hidden;
      white-space: nowrap;
      background-color rgba(7, 17, 27, 0.2)
      line-height 28px
      color #fff
      position relative
      .bulletin
        vertical-align top
        display inline-block
        width 22px
        height 12px
        margin-right 4px
        margin-top 7px
        bg-image('bulletin')
        background-size 22px 12px
        background-repeat no-repeat
      .text
        vertical-align top
        font-size 10px
      .icon-keyboard_arrow_right
        font-size 10px
        position absolute
        top: 0
        right 12px
        line-height 28px

    .background
      position absolute
      top: 0
      right 0
      width 100%
      height 100%
      z-index -1
      filter blur(10px)
    .detail
      position fixed
      top: 0
      left: 0
      width 100%
      height: 100%
      z-index 100
      overflow auto
      background-color rgba(7,17,27,0.8)
      backdrop-filter blur(10px)
      transition all 0.5s
      .detail-wrapper
        min-height 100%
        width 100%
        .detail-main
          margin-top 64px
          padding-bottom 64px
          .name
            font-size 16px
            font-weight 700
            line-height 16px
            text-align center
          .star-wrapper
            margin 16px auto 0
            padding 2px 0
            text-align center
          .detail-news
            display flex
            margin 28px auto 24px
            width 80%
            .line
              flex 1
              position relative
              top: -6px
              bottom 0
              border-bottom 1px solid rgba(255, 255, 255, 0.2)
            .text
              font-size 14px
              font-weight 700
              padding 0 12px
          .detail-notices
            display flex
            margin 28px auto 24px
            width 80%
            .line
              flex 1
              position relative
              top: -6px
              bottom 0
              border-bottom 1px solid rgba(255, 255, 255, 0.2)
            .text
              font-size 14px
              font-weight 700
              padding 0 12px
          .detail-supports
            width 80%
            padding 0 12px
            margin 0 auto
            .detail-item
              margin-bottom 12px
              line-height 12px
              &:last-child
                margin-bottom 0
              .icon
                display inline-block
                width 16px
                height 16px
                background-size 16px 16px
                background-repeat no-repeat
                vertical-align top
                &.decrease
                  bg-image('decrease_2')
                &.discount
                  bg-image('discount_2')
                &.guarantee
                  bg-image('guarantee_2')
                &.invoice
                  bg-image('invoice_2')
                &.special
                  bg-image('special_2')
              .text
                font-size 14px

          .detail-bulletin
            width 80%
            padding 0 12px
            margin 0 auto
            font-size 14px
            font-weight 200
            line-height 24px


      .detail-close
        position relative
        margin -64px auto 0 auto
        width 32px
        height 32px
        font-size 32px

</style>
